using System;
using System.Collections.Generic;
using System.Text;
using NHibernate;
using Atom.Data.BusinessObjects;
using Atom.Data.Base;

namespace Atom.Data.ManagerObjects
{
    public partial interface IHLeavehoschargeDetailManager : IManagerBase<Atom.Data.BusinessObjects.HLeavehoschargeDetail, string>
    {
		// Get Methods
		HLeavehoschargeDetail GetById(System.String inhosid, System.Int32 currentinhosmark, System.String detailaccountid, System.Int32 cancelmark);
    }

    partial class HLeavehoschargeDetailManager : ManagerBase<Atom.Data.BusinessObjects.HLeavehoschargeDetail, string>, IHLeavehoschargeDetailManager
    {
		#region Constructors
		
		public HLeavehoschargeDetailManager() : base()
        {
        }
        public HLeavehoschargeDetailManager(INHibernateSession session) : base(session)
        {
        }
		
		#endregion
		
        #region Get Methods

		public override HLeavehoschargeDetail GetById(string id)
		{
			string[] keys = id.Split('^');
			
			if(keys.Length != 4)
				throw new Exception("Invalid Id for HLeavehoschargeDetailManager.GetById");
			
			return GetById(keys[0], System.Int32.Parse(keys[1]), keys[2], System.Int32.Parse(keys[3]));
		}
		public HLeavehoschargeDetail GetById(System.String inhosid, System.Int32 currentinhosmark, System.String detailaccountid, System.Int32 cancelmark)
		{
			ICriteria criteria = Session.GetISession().CreateCriteria(typeof(HLeavehoschargeDetail));
			
			criteria.Add(NHibernate.Criterion.Expression.Eq("Inhosid", inhosid));
			criteria.Add(NHibernate.Criterion.Expression.Eq("Currentinhosmark", currentinhosmark));
			criteria.Add(NHibernate.Criterion.Expression.Eq("Detailaccountid", detailaccountid));
			criteria.Add(NHibernate.Criterion.Expression.Eq("Cancelmark", cancelmark));
			
			HLeavehoschargeDetail result = (HLeavehoschargeDetail)criteria.UniqueResult();

            if (result == null)
                throw new NHibernate.ObjectDeletedException("", null, null);

            return result;
		}
		
		
		#endregion
    }
}